var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("AssetsMap"),
    c = e("BundleNames"),
    l = e("ListView"),
    d = (e("Util"), e("ConfigGameData")),
    u = e("GameData"),
    p = e("GameOverData"),
    h = e("LoginProxy"),
    f = e("SkinLevelData"),
    _ = cc._decorator,
    y = _.ccclass,
    m = _.property,
    g = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (t.listView = null), (t.btn_close = null), (t.clickToggleIndex = 0), (t.gameDatalist = []), t;
        }
        return (
            a(t, e),
            (t.prototype.addEvent = function () {
                this.btn_close.on(game.EngineEventType.NodeEvent.click, this.onClick_btnClose, this);
            }),
            (t.prototype.removeEvent = function () {
                this.btn_close.off(game.EngineEventType.NodeEvent.click, this.onClick_btnClose, this);
            }),
            (t.prototype.onClick_btnClose = function () {
                this.closeView(!1),
                    ad.curr_platform == window.ad.Platform.OPPO && ad.adInterface.isNativePatchReady()
                        ? game.PopupManager.instance.showPopView(s.default.PopupMap.GameOverView2_1, null, !1, !1)
                        : game.PopupManager.instance.showPopView(
                              s.default.PopupMap.GameOverView2,
                              {ttShare: !1},
                              !1,
                              !1
                          );
            }),
            (t.prototype.onLoad = function () {
                this.isCache = !1;
            }),
            (t.prototype.start = function () {
                ad.curr_platform == window.ad.Platform.QQ && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.WECHAT && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.TOU_TIAO && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.MEI_ZU && ad.adInterface.showInterstitial(),
                    ad.curr_platform == window.ad.Platform.HUAWEI_GAME && ad.adInterface.showNativeInterstitial(),
                    ad.curr_platform == window.ad.Platform.BAI_DU && ad.adInterface.showBanner(),
                    ad.curr_platform == window.ad.Platform.OPPO && ad.adInterface.hideNativeBanner(!1),
                    ad.curr_platform == window.ad.Platform.VIVO &&
                        (ad.adInterface.hideNativeBanner(!1), ad.adInterface.hideBanner(!1)),
                    this.clickToggle1();
            }),
            (t.prototype.onDisable = function () {
                ad.curr_platform == window.ad.Platform.BAI_DU && ad.adInterface.hideBanner(!1);
            }),
            (t.prototype.btnClick_back = function (e) {
                "toggle1" == e.node.name
                    ? this.clickToggle1()
                    : "toggle2" == e.node.name
                    ? this.clickToggle2()
                    : "toggle3" == e.node.name
                    ? this.clickToggle3()
                    : "toggle4" == e.node.name && this.clickToggle4();
            }),
            (t.prototype.clickToggle4 = function () {
                (this.clickToggleIndex = 4), (this.gameDatalist = p.default.instance.getList4()), this.clickToggle();
            }),
            (t.prototype.clickToggle3 = function () {
                (this.clickToggleIndex = 3), (this.gameDatalist = p.default.instance.getList3()), this.clickToggle();
            }),
            (t.prototype.clickToggle2 = function () {
                (this.clickToggleIndex = 2), (this.gameDatalist = p.default.instance.getList2()), this.clickToggle();
            }),
            (t.prototype.clickToggle1 = function () {
                (this.clickToggleIndex = 1), (this.gameDatalist = p.default.instance.getList1()), this.clickToggle();
            }),
            (t.prototype.clickToggle = function () {
                for (var e = 1; e < 5; e++)
                    this.listView.node.getChildByName("label" + e).active = e == this.clickToggleIndex;
                this.listView.refreshHandler(this.gameDatalist, this.refreshItem, this);
            }),
            (t.prototype.refreshItem = function (e, t, o) {
                if (o < 3) {
                    var n = game.BundleManager.instance
                        .getBundle(c.default.Popup)
                        .get(
                            s.default.PopupMap.GameOverView1.preAssets.textures.assetsList["rankItemBg" + (o + 1)],
                            cc.SpriteFrame
                        );
                    (e.getChildByName("rankItemBg1").getComponent(cc.Sprite).spriteFrame = n),
                        (e.getChildByName("rankItemBg1").getChildByName("label_rank").active = !1);
                } else {
                    var i = game.BundleManager.instance
                        .getBundle(c.default.Popup)
                        .get(
                            s.default.PopupMap.GameOverView1.preAssets.textures.assetsList.rankItemBg4,
                            cc.SpriteFrame
                        );
                    (e.getChildByName("rankItemBg1").getComponent(cc.Sprite).spriteFrame = i),
                        (e.getChildByName("rankItemBg1").getChildByName("label_rank").active = !0),
                        (e.getChildByName("rankItemBg1").getChildByName("label_rank").getComponent(cc.Label).string =
                            o + 1 + "");
                }
                (e.getChildByName("rankItemBg").active = o % 2 == 0),
                    (e.getChildByName("label_name").getComponent(cc.Label).string = t.snake_name),
                    1 == this.clickToggleIndex
                        ? (e.getChildByName("label_score").getComponent(cc.Label).string = t.score + "")
                        : 2 == this.clickToggleIndex
                        ? (e.getChildByName("label_score").getComponent(cc.Label).string = t.score + t.oldScore + "")
                        : 3 == this.clickToggleIndex
                        ? (e.getChildByName("label_score").getComponent(cc.Label).string = t.killNum + "")
                        : 4 == this.clickToggleIndex &&
                          (e.getChildByName("label_score").getComponent(cc.Label).string = t.killScore + "");
                var a = t.randLevel,
                    r = game.BundleManager.instance
                        .getBundle(c.default.Start)
                        .get(s.default.StartBundle.textures.assetsList[a], cc.SpriteFrame);
                if (
                    ((e.getChildByName("gameLevel").getComponent(cc.Sprite).spriteFrame = r),
                    t.snake_name == u.default.instance.UserName)
                )
                    game.appFacade.retrieveProxy(h.default.NAME).loginVO.userInfo,
                        cc.assetManager.loadBundle("popup", function (t, o) {
                            if (!t) {
                                var n = u.default.instance.getUserSkin(),
                                    i = f.SkinLevelData.instance.skinList[n];
                                o.load("textures/EggView/skin_icon/" + i.name, cc.SpriteFrame, function (t, o) {
                                    if (t)
                                        return (
                                            console.log("加载头像出错：", "textures/EggView/skin_icon/" + i.name),
                                            void cc.error(t.message || t)
                                        );
                                    e
                                        .getChildByName("UserProfile")
                                        .getChildByName("mask")
                                        .getChildByName("user_icon")
                                        .getComponent(cc.Sprite).spriteFrame = o;
                                });
                            }
                        });
                else {
                    var l = d.default.instance.getIconByAIName(t.snake_name);
                    cc.assetManager.loadBundle("popup", function (t, o) {
                        t ||
                            o.load(l, cc.SpriteFrame, function (t, n) {
                                if (t)
                                    return (
                                        console.log("排位结束加载头像出错：", l),
                                        void o.load(
                                            "textures/EggView/skin_icon/kitty",
                                            cc.SpriteFrame,
                                            function (t, o) {
                                                if (t)
                                                    return (
                                                        console.log("排位结束加载头像出错：", l),
                                                        void cc.error(t.message || t)
                                                    );
                                                e
                                                    .getChildByName("UserProfile")
                                                    .getChildByName("mask")
                                                    .getChildByName("user_icon")
                                                    .getComponent(cc.Sprite).spriteFrame = o;
                                            }
                                        )
                                    );
                                e
                                    .getChildByName("UserProfile")
                                    .getChildByName("mask")
                                    .getChildByName("user_icon")
                                    .getComponent(cc.Sprite).spriteFrame = n;
                            });
                    });
                }
            }),
            r([m(l.default)], t.prototype, "listView", void 0),
            r([m(cc.Node)], t.prototype, "btn_close", void 0),
            r([y], t)
        );
    })(game.BasePopView);
i.default = g;
